﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIP.Data.Entities;

namespace VIP.Data
{
    public class VIPDbRWContext : DbContext
    {
        /// <summary>
        /// 使用外部配置
        /// </summary>
        /// <param name="opt"></param>
        public VIPDbRWContext(DbContextOptions<VIPDbRWContext> opt) : base(opt)
        {

        }
        protected VIPDbRWContext(DbContextOptions opt) : base(opt)
        {

        }
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            //model first 模式
            //modelBuilder.Entity<UserEntity>(u =>
            //{
            //    //设置表映射
            //    u.ToTable("Users");
            //    //设置索引
            //    u.HasIndex(u => new
            //    {
            //        u.Name
            //    });
            //});
        }
    }
}
